package teshop.data.dao.jpa;

import java.util.List;

import javax.persistence.Query;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import teshop.data.dao.CatalogDAO;
import teshop.data.domain.Product;


@Repository
@Transactional
public class JPACatalogDAO extends JPAGeneralDAO<Product, Long> implements CatalogDAO {

	@SuppressWarnings("unchecked")
	@Override
	public List<Product> getItemsList(int firstItem, int batchSize) {
		Query query = manager.createQuery("SELECT object(o) FROM Item AS o");
		query.setFirstResult(firstItem);
		query.setMaxResults(batchSize);
		
		return query.getResultList();
	}

}
